/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.d2g.realestate.facade;

import br.com.d2g.realestate.persistence.Client;
import br.com.d2g.realestate.persistence.User;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;

/**
 *
 * @author d2g
 */
@Stateless
public class ClientFacade extends AbstractFacade<Client> {
    @PersistenceContext(unitName = "WebApplication2PU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public ClientFacade() {
        super(Client.class);
    }
    
    public List<Client> searchClientByUsername(String username, int[] range) {
        TypedQuery searchClientByUsernameQuery = this.em.createNamedQuery("Client.findByUsername", Client.class);
        searchClientByUsernameQuery.setParameter("username", username);
        searchClientByUsernameQuery.setMaxResults(range[1] - range[0]);
        searchClientByUsernameQuery.setFirstResult(range[0]);
        return searchClientByUsernameQuery.getResultList();
    }

    public int countSearchClientByUsername(String username) {
        return 1;
    }
    
}
